<?php

/**
 * PlaygroundCommand class
 *
 * @author Julot
 * @since Friday, April 20, 2012. 05:41 PM
 */
class PlaygroundCommand extends CConsoleCommand {

	public function getHelp() {
		return <<<EOD
DESCRIPTION
    Just a playground
EOD;
	}

	public function run($args) {
//		$this->extractMultiTiff();
//		$this->extractSingleTiff();
		$this->sendEmail();
	}

	protected function sendEmail() {
		Yii::app()->email->send('ai.yori.aoshi.2012@gmail.com',
			'andy.julot@gmail.com', 'Testing Send Email Using KEmail',
			'Just a test using Yii KEmail Extension'
		);
	}

	protected function extractMultiTiff() {
		$basePath = Yii::app()->basePath;
		$playPath = "$basePath/commands/playground";
		$multi = "$playPath/multi.tif";
		$images = new Imagick($multi);
		foreach ($images as $i=>$image) {
			$image->writeimage("$playPath/multi.$i.jpg");
			$image->thumbnailImage(200, 0);
			$image->writeImage("$playPath/multi.$i.thumb.jpg");
		}
		$images->clear();
	}

	protected function extractSingleTiff() {
		$basePath = Yii::app()->basePath;
		$playPath = "$basePath/commands/playground";
		$multi = "$playPath/single.tif";
		$images = new Imagick($multi);
		foreach ($images as $i=>$image) {
			$image->writeimage("$playPath/single.$i.png");
			$image->thumbnailImage(200, 0);
			$image->writeImage("$playPath/single.$i.thumb.png");
		}
		$images->clear();
	}

}
